import 'package:love_newf/app/com/base/L.dart';
import 'package:love_newf/app/com/model/user_info_model.dart';
import 'package:love_newf/app/page/live/live_logic.dart';
import 'package:love_newf/generated/json/base/json_field.dart';
import 'package:love_newf/generated/json/room_data_model.g.dart';
import 'dart:convert';
export 'package:love_newf/generated/json/room_data_model.g.dart';

@JsonSerializable()
class RoomDataModel {
  ///消息类型 1 赠送礼物，2 申请上麦，3 通知用户推流，4 麦位信息变更，5 加冕天使，6 3人间-专属房相互转换，7 进场特效，8专属房开始计时，9 申请上麦，在线人数变化，10 开始/结束PK，11 K歌最新数据通知
  int msgType = 0;
  int roomLiveCheck = 0;
  int requestId = 0;
  RoomDataApplyOnlineVo? applyOnlineVo;
  RoomDataGivePropMsg? givePropMsg;
  RoomDataInputSteamMsg? inputSteamMsg;
  RoomDataBindAngelVO? bindAngelVO;
  RoomDataRoomChangeVO? roomChangeVO;
  RoomDataJoinRoomEffectVO? joinRoomEffectVO;
  List<RoomDataRoomMais> roomMais = [];
  RoomDataRoomPKVO? roomPKVO;
  RoomDataMusicMsgVO? musicMsgVO;
  RoomDataToppingVO? toppingVO;
  RoomDataJoinTrainVO? joinTrainVO;

  RoomDataModel();

  factory RoomDataModel.fromJson(Map<String, dynamic> json) =>
      $RoomDataModelFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataModelToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataApplyOnlineVo {
  int applyCountMan = 0;
  int applyCountWoman = 0;
  int onlineCountMan = 0;
  int onlineCountWoman = 0;

  RoomDataApplyOnlineVo();

  factory RoomDataApplyOnlineVo.fromJson(Map<String, dynamic> json) =>
      $RoomDataApplyOnlineVoFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataApplyOnlineVoToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsg {
  UserInfoModel? sendUserVO;
  int userId = 0;
  int receiveUserId = 0;
  String receiveNick = '';
  int propId = 0;
  int action = 0;
  int amount = 0;
  List<RoomDataGivePropMsgRankVOS> rankVOS = [];
  List<RoomDataGivePropMsgAnchorReceiveRankVOS> anchorReceiveRankVOS = [];
  RoomDataGivePropMsgWishRoomUserVO? wishRoomUserVO;

  RoomDataGivePropMsg();

  factory RoomDataGivePropMsg.fromJson(Map<String, dynamic> json) =>
      $RoomDataGivePropMsgFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataGivePropMsgToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsgSendUserVO {
  int userId = 0;
  String userCode = '';
  String avatar = '';
  String nick = '';
  int sex = 0;
  int age = 0;
  String avatarFrameUrl = '';
  int vipGrade = 0;
  List<RoomDataGivePropMsgSendUserVOUserLabels> userLabels = [];
  int prohibition = 0;
  String beautifulCodeUrl = '';
  String chatFrameUrl = '';

  RoomDataGivePropMsgSendUserVO();

  factory RoomDataGivePropMsgSendUserVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataGivePropMsgSendUserVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataGivePropMsgSendUserVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsgSendUserVOUserLabels {
  int anchorUserId = 0;
  String labelName = '';
  int labelType = 0;
  String url = '';

  RoomDataGivePropMsgSendUserVOUserLabels();

  factory RoomDataGivePropMsgSendUserVOUserLabels.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataGivePropMsgSendUserVOUserLabelsFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataGivePropMsgSendUserVOUserLabelsToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsgRankVOS {
  int userId = 0;
  int tokens = 0;
  String avatar = '';

  RoomDataGivePropMsgRankVOS();

  factory RoomDataGivePropMsgRankVOS.fromJson(Map<String, dynamic> json) =>
      $RoomDataGivePropMsgRankVOSFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataGivePropMsgRankVOSToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsgAnchorReceiveRankVOS {
  int anchorUserId = 0;
  String nick = '';
  int maiIndex = 0;
  List<RoomDataGivePropMsgAnchorReceiveRankVOSWishes> wishes = [];
  int receiveTotal = 0;
  List<RoomDataGivePropMsgAnchorReceiveRankVOSRankVOS> rankVOS = [];

  RoomDataGivePropMsgAnchorReceiveRankVOS();

  factory RoomDataGivePropMsgAnchorReceiveRankVOS.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataGivePropMsgAnchorReceiveRankVOSFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataGivePropMsgAnchorReceiveRankVOSToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsgAnchorReceiveRankVOSWishes {
  int id = 0;
  int userId = 0;
  int propId = 0;
  int propNum = 0;
  int propReceive = 0;
  int status = 0;
  int propOrder = 0;
  String createTime = '';
  int deleteFlag = 0;

  RoomDataGivePropMsgAnchorReceiveRankVOSWishes();

  factory RoomDataGivePropMsgAnchorReceiveRankVOSWishes.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataGivePropMsgAnchorReceiveRankVOSWishesFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataGivePropMsgAnchorReceiveRankVOSWishesToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsgAnchorReceiveRankVOSRankVOS {
  int userId = 0;
  int tokens = 0;
  String avatar = '';

  RoomDataGivePropMsgAnchorReceiveRankVOSRankVOS();

  factory RoomDataGivePropMsgAnchorReceiveRankVOSRankVOS.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataGivePropMsgAnchorReceiveRankVOSRankVOSFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataGivePropMsgAnchorReceiveRankVOSRankVOSToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataGivePropMsgWishRoomUserVO {
  int propNum = 0;
  int propReceive = 0;

  RoomDataGivePropMsgWishRoomUserVO();

  factory RoomDataGivePropMsgWishRoomUserVO.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataGivePropMsgWishRoomUserVOFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataGivePropMsgWishRoomUserVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataInputSteamMsg {
  int roomId = 0;
  int userId = 0;
  int maiIndex = 0;
  String inputStreamId = '';
  int maiOpen = 0;
  int maiStatus = 0; //麦位状态 0 空闲，1 占用，2 掉线
  int exclusive = 0;
  int roomType = 0;

  RoomDataInputSteamMsg();

  factory RoomDataInputSteamMsg.fromJson(Map<String, dynamic> json) =>
      $RoomDataInputSteamMsgFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataInputSteamMsgToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataBindAngelVO {
  int anchorUserId = 0;
  int maiIndex = 0;
  String anchorAvatar = '';
  int userId = 0;
  String avatar = '';
  int angelType = 0;
  int propId = 0;

  RoomDataBindAngelVO();

  factory RoomDataBindAngelVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataBindAngelVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataBindAngelVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomChangeVO {
  int tokens = 0;
  int userId = 0;
  int roomType = 0;

  RoomDataRoomChangeVO();

  factory RoomDataRoomChangeVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataRoomChangeVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataRoomChangeVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataJoinRoomEffectVO {
  int userId = 0;
  String nick = '';
  String avatar = '';
  int propId = 0;
  String bannerUrl = '';

  RoomDataJoinRoomEffectVO();

  factory RoomDataJoinRoomEffectVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataJoinRoomEffectVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataJoinRoomEffectVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomMais {
  int id = 0;
  String inputStreamId = '';
  String outputStreamId = '';
  int roomId = 0;
  int userId = 0;
  int sex = 0;
  int maiIndex = 0;

  ///麦位状态 0 空闲，1 占用，2 掉线
  int status = 0;
  int maiOpen = 0;
  String shangMaiTime = '';
  String xiaMaiTime = '';
  int liveMinutes = 0;
  int receiveTokens = 0;
  int deleteFlag = 0;
  List<RoomDataRoomMaisRoomAnchorStickersList> roomAnchorStickersList = [];
  RoomDataRoomMaisMusicVO? musicVO;
  String avatar = '';
  String nick = '';

  RoomDataRoomMais();

  bool isAnchor() => userId == L.userInfo.userId;

  int getReceiveTokens() {
    for (RoomDataGivePropMsgAnchorReceiveRankVOS item
        in LiveLogic.logic?.roomData?.givePropMsg?.anchorReceiveRankVOS ?? []) {
      if (item.maiIndex == maiIndex) {
        return item.receiveTotal;
      }
    }
    return 0;
  }

  List<RoomDataGivePropMsgAnchorReceiveRankVOSRankVOS> getRankVOS() {
    for (RoomDataGivePropMsgAnchorReceiveRankVOS item
        in LiveLogic.logic?.roomData?.givePropMsg?.anchorReceiveRankVOS ?? []) {
      if (item.maiIndex == maiIndex) {
        return item.rankVOS;
      }
    }
    return [];
  }

  factory RoomDataRoomMais.fromJson(Map<String, dynamic> json) =>
      $RoomDataRoomMaisFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataRoomMaisToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomMaisRoomAnchorStickersList {
  int propId = 0;
  int count = 0;
  String lastTime = '';

  RoomDataRoomMaisRoomAnchorStickersList();

  factory RoomDataRoomMaisRoomAnchorStickersList.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataRoomMaisRoomAnchorStickersListFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataRoomMaisRoomAnchorStickersListToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomMaisMusicVO {
  int userId = 0;
  String nick = '';
  String avatar = '';
  int pointUserId = 0;
  String pointNick = '';
  String pointAvatar = '';
  String musicSerialNumber = '';
  int musicStatus = 0;
  String musicName = '';
  String createTime = '';

  RoomDataRoomMaisMusicVO();

  factory RoomDataRoomMaisMusicVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataRoomMaisMusicVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataRoomMaisMusicVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomPKVO {
  int roomId = 0;
  int pkType = 0;
  RoomDataRoomPKVOPkGroupVO? pkGroupVO;
  List<RoomDataRoomPKVOPkUserVOS> pkUserVOS = [];
  int isStart = 0;
  int minutes = 0;
  String orderNo = '';
  String createTime = '';
  int endSecond = 0;

  RoomDataRoomPKVO();

  factory RoomDataRoomPKVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataRoomPKVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataRoomPKVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomPKVOPkGroupVO {
  List<RoomDataRoomPKVOPkGroupVOGroupRed> groupRed = [];
  List<RoomDataRoomPKVOPkGroupVOGroupBlue> groupBlue = [];
  int tokensRed = 0;
  int tokensBlue = 0;

  RoomDataRoomPKVOPkGroupVO();

  factory RoomDataRoomPKVOPkGroupVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataRoomPKVOPkGroupVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataRoomPKVOPkGroupVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomPKVOPkGroupVOGroupRed {
  int userId = 0;
  String nick = '';
  String avatar = '';
  int tokens = 0;
  int group = 0;

  RoomDataRoomPKVOPkGroupVOGroupRed();

  factory RoomDataRoomPKVOPkGroupVOGroupRed.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataRoomPKVOPkGroupVOGroupRedFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataRoomPKVOPkGroupVOGroupRedToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomPKVOPkGroupVOGroupBlue {
  int userId = 0;
  String nick = '';
  String avatar = '';
  int tokens = 0;
  int group = 0;

  RoomDataRoomPKVOPkGroupVOGroupBlue();

  factory RoomDataRoomPKVOPkGroupVOGroupBlue.fromJson(
          Map<String, dynamic> json) =>
      $RoomDataRoomPKVOPkGroupVOGroupBlueFromJson(json);

  Map<String, dynamic> toJson() =>
      $RoomDataRoomPKVOPkGroupVOGroupBlueToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataRoomPKVOPkUserVOS {
  int userId = 0;
  String nick = '';
  String avatar = '';
  int tokens = 0;
  int group = 0;

  RoomDataRoomPKVOPkUserVOS();

  factory RoomDataRoomPKVOPkUserVOS.fromJson(Map<String, dynamic> json) =>
      $RoomDataRoomPKVOPkUserVOSFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataRoomPKVOPkUserVOSToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataMusicMsgVO {
  int requestId = 0;
  int musicJumpTokens = 0;
  int musicPropId = 0;
  int pointPeople = 0;
  int pointAmount = 0;
  int numberOneUserId = 0;
  int numberOneTokens = 0;
  List<RoomDataMusicMsgVOMusicUsers> musicUsers = [];

  RoomDataMusicMsgVO();

  factory RoomDataMusicMsgVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataMusicMsgVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataMusicMsgVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataMusicMsgVOMusicUsers {
  int userId = 0;
  int receiveTokens = 0;
  int jumpNeedTokens = 0;
  int musicStatus = 0;
  int receiveTime = 0;

  RoomDataMusicMsgVOMusicUsers();

  factory RoomDataMusicMsgVOMusicUsers.fromJson(Map<String, dynamic> json) =>
      $RoomDataMusicMsgVOMusicUsersFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataMusicMsgVOMusicUsersToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataToppingVO {
  int roomId = 0;
  int maiIndex = 0;

  RoomDataToppingVO();

  factory RoomDataToppingVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataToppingVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataToppingVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class RoomDataJoinTrainVO {
  int userId = 0;
  String nick = '';
  String avatar = '';
  String userCode = '';
  int roomId = 0;

  RoomDataJoinTrainVO();

  factory RoomDataJoinTrainVO.fromJson(Map<String, dynamic> json) =>
      $RoomDataJoinTrainVOFromJson(json);

  Map<String, dynamic> toJson() => $RoomDataJoinTrainVOToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
